#include "Table.h"

Records::Iterator::Iterator(Records & records)
: records(records)
, index(0)
{
}
Records::Iterator::~Iterator(){
}
bool Records::Iterator::hasNext(){
    return index < records.size() - 1;
}
Records::Record * Records::Iterator::next(){
    return records.get(index);
}

Records::Records(){
}
Records::~Records(){
    clear();
}

Records::Iterator Records::iterator() {
    return Records::Iterator(*this);
}

std::string Records::toString() const {
    std::ostringstream oss;
    oss << "Records: size:" << records.size() << std::endl;
    auto it = records.begin();
    for(; it != records.end(); ++it){
        oss << "\tk:" << (*it)->first << "v:" << (*it)->second << ",\n";
    }
    return oss.str();
}
int Records::pushBack(const int key, const  char * value){
    auto rec = new Record(key, value);
    records.push_back(rec);
    return 0;
}
void Records::clear(){
    auto it = records.begin();
    for(; it != records.end(); ++it){
        delete *it;
    }
    records.clear();
}

Table::Table(const std::string & name)
:name(name)
{
}
Table::~Table() {
}

std::string Table::toString() const {
    return std::string("TabelInt");
}

